﻿namespace NTLib.WPF.Interactions
{
    using Core.Log;
    using Interactions;
    using Resources;
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Collections.Specialized;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Markup;
    using Core.Exceptions;
    using Core.Extensions;

    /// <summary>
    /// Base class used to easily implement an action trigger in WPF.
    /// </summary>
    /// <seealso cref="System.Windows.DependencyObject" />
    /// <seealso cref="NTLib.WPF.Interactions.IInteraction" />
    public abstract class BaseTrigger<TDependecyObject> : BaseInteractionContainer<TDependecyObject, BaseActioner<TDependecyObject>> //Freezable, IInteraction
        where TDependecyObject : DependencyObject
    {
        #region Methods

        /// <summary>
        /// Raise
        /// </summary>
        protected void Raise(object parameters)
        {
            if (Children == null)
                return;
            foreach (var action in Children)
            {
                try
                {
                    action.Invoke(parameters);
                }
                catch (Exception ex)
                {
                    NTLog.Instance.RecordError(ex, this.GetType().Name);
                }
            }
        }

        #endregion
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TDependencyObject">The type of the dependency object.</typeparam>
    /// <seealso cref="System.Windows.DependencyObject" />
    /// <seealso cref="NTLib.WPF.Interactions.IInteraction" />
    public abstract class BaseTrigger : BaseTrigger<DependencyObject>
    {
    }
}
